package com.spring.datasource.controller;

import com.spring.datasource.config.model.User;
import com.spring.datasource.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping
    public String save(@RequestBody User user){

        this.userService.insert(user);

        return "Success";
    }

    @GetMapping
    public User get(Long id){
        return this.userService.get(id);
    }
}
